package com.xixi.controller;

import com.xixi.pojo.vo.Result;
import com.xixi.pojo.vo.statistics.order.OrderStatsVO;
import com.xixi.pojo.vo.statistics.order.OrderStatusVO;
import com.xixi.pojo.vo.statistics.order.OrderTrendVO;
import com.xixi.pojo.vo.statistics.personal.PersonalTradingAnalysisVO;
import com.xixi.pojo.vo.statistics.personal.PersonalTradingTrendVO;
import com.xixi.pojo.vo.statistics.product.ProductCategoryVO;
import com.xixi.pojo.vo.statistics.product.ProductStatsVO;
import com.xixi.pojo.vo.statistics.product.ProductStatusVO;
import com.xixi.pojo.vo.statistics.user.UserGenderVO;
import com.xixi.pojo.vo.statistics.user.UserRegisterVO;
import com.xixi.pojo.vo.statistics.user.UserStatsVO;
import com.xixi.service.OrderService;
import com.xixi.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statsService;

    @GetMapping("/orderStats")
    public Result getOrderStats() {
        OrderStatsVO stats = statsService.getOrderStats();
        return Result.success(stats);
    }

    @GetMapping("/orderTrend")
    public Result getOrderTrend() {
        List<OrderTrendVO> trend = statsService.getOrderTrend();
        return Result.success(trend);
    }

    @GetMapping("/orderStatus")
    public Result getOrderStatus() {
        List<OrderStatusVO> status = statsService.getOrderStatus();
        return Result.success(status);
    }
    @GetMapping("/productCategory")
    public Result getProductCategory() {
        List<ProductCategoryVO> category = statsService.getProductCategory();
        return Result.success(category);
    }
    @GetMapping("/productStats")
    public Result getProductStats() {
        ProductStatsVO stats = statsService.getProductStats();
        return Result.success(stats);
    }
    @GetMapping("/productStatus")
    public Result getProductStatus() {
        List<ProductStatusVO> status = statsService.getProductStatus();
        return Result.success(status);
    }
    @GetMapping("/userStats")
    public Result getUserStats() {
        UserStatsVO stats = statsService.getUserStats();
        return Result.success(stats);
    }
    @GetMapping("/userGender")
    public Result getUserGender() {
        List<UserGenderVO> gender = statsService.getUserGender();
        return Result.success(gender);
    }
    @GetMapping("/userRegister")
    public Result getUserRegister() {
        List<UserRegisterVO> register = statsService.getUserRegister();
        return Result.success(register);
    }
    // 个人商品统计
    @GetMapping("/personal/productStats/{userId}")
    public Result getPersonalProductStats(@PathVariable Integer userId) {
        ProductStatsVO stats = statsService.getPersonalProductStats(userId);
        return Result.success(stats);
    }

    // 个人商品分类分布
    @GetMapping("/personal/productCategory/{userId}")
    public Result getPersonalProductCategory(@PathVariable Integer userId) {
        List<ProductCategoryVO> category = statsService.getPersonalProductCategory(userId);
        return Result.success(category);
    }

    // 个人商品状态分布
    @GetMapping("/personal/productStatus/{userId}")
    public Result getPersonalProductStatus(@PathVariable Integer userId) {
        List<ProductStatusVO> status = statsService.getPersonalProductStatus(userId);
        return Result.success(status);
    }
    // 个人订单统计
    @GetMapping("/personal/orderStats/{userId}")
    public Result getPersonalOrderStats(@PathVariable Integer userId) {
        OrderStatsVO stats = statsService.getPersonalOrderStats(userId);
        return Result.success(stats);
    }

    // 个人订单状态分布
    @GetMapping("/personal/orderStatus/{userId}")
    public Result getPersonalOrderStatus(@PathVariable Integer userId) {
        List<OrderStatusVO> status = statsService.getPersonalOrderStatus(userId);
        return Result.success(status);
    }

    // 个人订单趋势
    @GetMapping("/personal/orderTrend/{userId}")
    public Result getPersonalOrderTrend(@PathVariable Integer userId) {
        List<OrderTrendVO> trend = statsService.getPersonalOrderTrend(userId);
        return Result.success(trend);
    }
    // 个人交易趋势分析
    @GetMapping("/personal/tradingTrend/{userId}")
    public Result getPersonalTradingTrend(@PathVariable Integer userId) {
        List<PersonalTradingTrendVO> trend = statsService.getPersonalTradingTrend(userId);
        return Result.success(trend);
    }

    // 个人交易综合分析
    @GetMapping("/personal/tradingAnalysis/{userId}")
    public Result getPersonalTradingAnalysis(@PathVariable Integer userId) {
        PersonalTradingAnalysisVO analysis = statsService.getPersonalTradingAnalysis(userId);
        return Result.success(analysis);
    }
}
